package com.engine4cloud.tdf.supervision.convert;

import com.engine4cloud.tdf.supervision.dto.create.SpAuditResultCreateDTO;
import com.engine4cloud.tdf.supervision.entity.SpAuditResultEntity;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.time.LocalDateTime;


@Mapper
public interface ActiveAuditConvert {
    ActiveAuditConvert INSTANCE = Mappers.getMapper(ActiveAuditConvert.class);

    SpAuditResultEntity createTo(SpAuditResultCreateDTO s);

    default SpAuditResultEntity create(SpAuditResultCreateDTO s, String username, Long tenantId, Long preDeptId) {
        SpAuditResultEntity entity = createTo(s);
        entity.setShsj(LocalDateTime.now());
        entity.setShry(username);
        entity.setShsm(s.getShsm());
        entity.setYwlx(s.getBusinessType());
        entity.setShjg(s.getStatus());
        entity.setTenantId(tenantId);
        entity.setPreDeptId(preDeptId);
        return entity;
    }

}
